﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using MyHospital.BLL;

namespace MyHospital.web.MyHospital
{
    public partial class NewUser : System.Web.UI.Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {

        }

        protected void btnReg_Click(object sender, EventArgs e)
        {
            if (Page.IsValid)
            {
                User user = new User();
                string txtSex = "";
                if (RadioButton1.Checked) txtSex = "男";
                else if (RadioButton2.Checked) txtSex = "女";
                if (!RadioButton1.Checked && !RadioButton2.Checked) lblMsg.Text = "性别未选择！";
                else
                {
                    if (user.isPhoneExit(txtPhone.Text) == true && user.isEmailExit(txtEmail.Text) == true)
                    {
                        user.insertPatient(txtName.Text, txtNickName.Text, txtSex, txtEmail.Text, txtPhone.Text, " ", txtPwd.Text, txtIDCard.Text);
                        lblMsg.Text = "注册成功！请登录";
                    }
                    else if (user.isPhoneExit(txtPhone.Text) == false && user.isEmailExit(txtEmail.Text) == true)
                    {
                        lblMsg.Text = "电话号码已被注册！";
                    }
                    else if (user.isPhoneExit(txtPhone.Text) == true && user.isEmailExit(txtEmail.Text) == false)
                    {
                        lblMsg.Text = "邮箱已被注册！";
                    }
                    else
                    {
                        lblMsg.Text = "邮箱和邮箱都已被注册！";
                    }
                }
            }
            
        }
    }
}